package com.sz.biz.logistics.ord.service.impl;

import com.sz.biz.common.constants.ErrorCodes;
import com.sz.common.base.dao.ParamData;
import com.sz.common.base.exception.Exceptions;
import com.sz.common.base.service.AbstractService;
import com.sz.biz.logistics.ord.entity.ConvertStatus;
import com.sz.biz.logistics.ord.entity.OrdTrackingOriginal;
import com.sz.biz.logistics.ord.service.OrdTrackingOriginalService;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
 * Package: com.sz.biz.logistics.ord.service.impl<br>
 * Function: 原始物流跟踪service
 * Author: yanhong.xiao.<br>
 * Date: 2017-05-11 21:13:00.
 */
@Service("ordTrackingOriginalService")
public class OrdTrackingOriginalServiceImpl extends AbstractService implements OrdTrackingOriginalService {
    @Override
    public int save(OrdTrackingOriginal trackingOriginal) {
        if (!ObjectUtils.isEmpty(trackingOriginal)) {
            dao.save(getSqlName("insertSelective"), trackingOriginal);
        }
        // 查看状态是否已经完成
        return trackingOriginal.getId();
    }

    @Override
    public void updateConvertStatus(int originalId, ConvertStatus convertStatus) {
        if (originalId <= 0 && ObjectUtils.isEmpty(convertStatus)) {
            throw Exceptions.bizException(ErrorCodes.ERROR_COMMON, "originalId or convertStatus exception");
        }
        ParamData pd = new ParamData();
        pd.put("id", originalId);
        pd.put("convertStatus", convertStatus);
        dao.update(getSqlName("updateConvertStatus"), pd);

    }

    @Override
    protected String getMapperNamespace() {
        return "com.sz.biz.logistics.ord.OrdTrackingOriginalMapper";
    }
}
